﻿<%@ Page Title="" Language="C#" MasterPageFile="~/TsSite.Master" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="TireService.Web.View.Index" %>

<%@ Register Assembly="DevExpress.Web.ASPxEditors.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxLoadingPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dx" %>

<%@ Register src="../UserControls/ucDeactivateSubscription.ascx" tagname="ucDeactivateSubscription" tagprefix="uc1" %>
<%@ Register src="../UserControls/ucReplaceCar.ascx" tagname="ucReplaceCar" tagprefix="uc2" %>
<%@ Register src="../UserControls/ucCreateTask.ascx" tagname="ucCreateTask" tagprefix="uc3" %>
<%@ Register src="../UserControls/ucCustomerBookingLink.ascx" tagname="ucCustomerBookingLink" tagprefix="uc4" %>

<%@ Register src="../UserControls/Tasks/ucEditTask.ascx" tagname="ucEditTask" tagprefix="uc5" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    

    <dx:ASPxLoadingPanel ID="LoadingPanel" Text="Vent venligst..." ClientInstanceName="LoadingPanel" runat="server" Modal="True">
    </dx:ASPxLoadingPanel>

    <!-- Javascript: Quick Search function  -->
    <script language="javascript" type="text/javascript">

        // Function for searching for customer on customerid
        function SearchOnCustomerId(s, e) {
            // Validate values
            txtCustomerId.Validate();

            var isFormValid = ASPxClientEdit.ValidateGroup("SearchOnCustomerId");
            if (isFormValid) {
                // Clear search result
                lblSearchResult.SetText('');

                // Prepare input for search (0: SearchType, 1: SearchValue)
                var input = 0 + '|' + txtCustomerId.GetText();

                // Callback server to get customers based on search
                gvCustomerSearch.PerformCallback(input);

                // Show loadingpanel
                LoadingPanel.Show();
            }
        }

        // Function for searching for customer on name
        function SearchOnName(s, e) {
            // Validate values
            txtName.Validate();

            var isFormValid = ASPxClientEdit.ValidateGroup("SearchOnName");
            if (isFormValid) {
                // Clear search result
                lblSearchResult.SetText('');

                // Prepare input for search (0: SearchType, 1: SearchValue)
                var input = 1 + '|' + txtName.GetText();

                // Callback server to get customers based on search
                gvCustomerSearch.PerformCallback(input);

                // Show loadingpanel
                LoadingPanel.Show();
            }
        }

        // Function for searching for customer on phone
        function SearchOnPhone(s, e) {
            // Validate values
            txtPhone.Validate();

            var isFormValid = ASPxClientEdit.ValidateGroup("SearchOnPhone");
            if (isFormValid) {
                // Clear search result
                lblSearchResult.SetText('');

                // Prepare input for search (0: SearchType, 1: SearchValue)
                var input = 2 + '|' + txtPhone.GetText();

                // Callback server to get customers based on search
                gvCustomerSearch.PerformCallback(input);

                // Show loadingpanel
                LoadingPanel.Show();
            }
        }

        // Function for searching for customer on email
        function SearchOnEmail(s, e) {
            // Validate values
            txtEmail.Validate();

            var isFormValid = ASPxClientEdit.ValidateGroup("SearchOnEmail");
            if (isFormValid) {
                // Clear search result
                lblSearchResult.SetText('');

                // Prepare input for search (0: SearchType, 1: SearchValue)
                var input = 3 + '|' + txtEmail.GetText();

                // Callback server to get customers based on search
                gvCustomerSearch.PerformCallback(input);

                // Show loadingpanel
                LoadingPanel.Show();
            }
        }

        // Function for searching for customer on email
        function SearchOnRegistrationNumber(s, e) {
            // Validate values
            txtRegistrationNumber.Validate();

            var isFormValid = ASPxClientEdit.ValidateGroup("SearchOnRegistrationNumber");
            if (isFormValid) {
                // Clear search result
                lblSearchResult.SetText('');

                // Prepare input for search (0: SearchType, 1: SearchValue)
                var input = 4 + '|' + txtRegistrationNumber.GetText();

                // Callback server to get customers based on search
                gvCustomerSearch.PerformCallback(input);

                // Show loadingpanel
                LoadingPanel.Show();
            }
        }

        // Function that runs when callback to server ends
        function CustomerSearchEnded(s, e) {
            if (gvCustomerSearch.pageRowCount > 0) {
                // Show gridview
                gvCustomerSearch.SetVisible(true);

                // Hide loadingpanel
                LoadingPanel.Hide();

//                if (gvCustomerSearch.pageRowCount == 1) {
//                    // Only one search result - Redirect to specific customer

//                    // Get first row values and trigger event RedirectToCustomerPage
//                    gvCustomerSearch.GetRowValues(0, 'CustomerId', RedirectToCustomerPage);
//                } else {
//                    // Hide loadingpanel
//                    LoadingPanel.Hide();
//                }

                lblSearchResult.SetText(gvCustomerSearch.pageRowCount + ' kunder matcher søge kriterier');

            }
            else {
                // Hide loadingpanel
                LoadingPanel.Hide();

                // Hide gridview
                gvCustomerSearch.SetVisible(false);
                
                alert('Søgning gav intet resultat');
            }
        }

        // Function for redirecting user to customer
        function RedirectToCustomerPage(value) {
            window.navigate('CustomerView/EditCustomerData.aspx?CustomerId=' + value);
        }

        // Function that runs when a customer is selected in gridview search result
        function CustomerSelected(s, e) {
//            if (gvCustomerSearch.GetFocusedRowIndex() != -1) {
//                gvCustomerSearch.GetRowValues(gvCustomerSearch.GetFocusedRowIndex(), 'CustomerId;CarId', ShowCustomerServiceDetails);
//            }
        }

        function ShowCustomerServiceDetails(carid) {
            if (carid == null) return;

            // Callback servicedrives and tasks
            gvService.PerformCallback(carid);
            gvTask.PerformCallback(carid);

            pcShowServiceDetails.Show();
        }

        // Function that return alert message with error on server callback
        function CallBackError(s, e) {
            alert('Fejl opstod: ' + e.message);
        }

        function SelectQuickAction(id, carid) {

            if (id != null) {
                // Create task
                if (id == 0) {

                    // Get customerid and carid
                    gvCustomerSearch.GetRowValues(gvCustomerSearch.GetFocusedRowIndex(), 'CustomerId;CarId', CreateTask);
                }

                // Overview service/tasks
                if (id == 1) {
                    ShowCustomerServiceDetails(carid);
                }

                // Replace car
                if (id == 2) {
                    ShowReplaceCarModalPopup(gvCustomerSearch, carid);
                }

                // Deactivate subscription
                if (id == 3) {

                    // Get customersubscriptionid
                    gvCustomerSearch.GetRowValues(gvCustomerSearch.GetFocusedRowIndex(), 'CustomerSubscriptionId', DeactiveSubscriptionCar);
                }

                // See/send booking link to customer
                if (id == 4) {
                    // Get customerid
                    gvCustomerSearch.GetRowValues(gvCustomerSearch.GetFocusedRowIndex(), 'CustomerId', ShowBookingLink);
                }
            }
            else {
                alert('Ingen handling valgt');
            }
        }

        function CreateTask(values) {
            if (values == null) return;
            if (values.length == 0) return;

            ShowCreateTaskModalPopup(gvCustomerSearch, values[0], values[1]);
        }
        
        function DeactiveSubscriptionCar(value) {
            ShowDeactivateCustomerSubscriptionModalPopup(gvCustomerSearch, value);
        }

        function ShowBookingLink(value) {
            SendCustomerBookingLinkModalPopup(gvCustomerSearch, value);
        }

    </script>

    <table>
        <tr>
            <td valign="top" style="width:420px">
                <table width="210px">
                    <tr>
                        <td colspan="3">
                            <b>Hurtig søgning - Kunder</b>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3">
                            <dx:ASPxLabel ID="lblSearchResult" ClientInstanceName="lblSearchResult" runat="server" Text="">
                            </dx:ASPxLabel>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Kundenr
                        </td>
                        <td>
                            <dx:ASPxTextBox ID="txtCustomerId" ClientInstanceName="txtCustomerId" runat="server" Width="100px">
                                <ValidationSettings CausesValidation="true" ValidationGroup="SearchOnCustomerId" RequiredField-IsRequired="true" RequiredField-ErrorText="Indtast kundenr" SetFocusOnError="true" ErrorDisplayMode="ImageWithTooltip">
                                    <RequiredField IsRequired="True" ErrorText="Indtast kundenr"></RequiredField>
                                </ValidationSettings>
                                <ClientSideEvents KeyDown="function(s, e) {if(ASPxClientUtils.GetKeyCode(e.htmlEvent) ===  ASPxKey.Enter) SearchOnCustomerId();}" />
                            </dx:ASPxTextBox>
                        </td>
                        <td>
                            <dx:ASPxButton ID="btnCustomerIdSearch" ClientInstanceName="btnCustomerIdSearch" runat="server" Text="Søg" AutoPostBack="False" UseSubmitBehavior="False">
                                <ClientSideEvents Click="function(s, e) { SearchOnCustomerId(); }" />
                            </dx:ASPxButton>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Navn
                        </td>
                        <td>
                            <dx:ASPxTextBox ID="txtName" ClientInstanceName="txtName" runat="server" Width="100px">
                                <ValidationSettings CausesValidation="true" ValidationGroup="SearchOnName" RequiredField-IsRequired="true" RequiredField-ErrorText="Indtast navn" SetFocusOnError="true" ErrorDisplayMode="ImageWithTooltip">
                                    <RequiredField IsRequired="True" ErrorText="Indtast navn"></RequiredField>
                                </ValidationSettings>
                                <ClientSideEvents KeyDown="function(s, e) {if(ASPxClientUtils.GetKeyCode(e.htmlEvent) ===  ASPxKey.Enter) SearchOnName();}" />
                            </dx:ASPxTextBox>
                        </td>
                        <td>
                            <dx:ASPxButton ID="btnNameSearch" ClientInstanceName="btnNameSearch" runat="server" Text="Søg" AutoPostBack="False" UseSubmitBehavior="False">
                                <ClientSideEvents Click="function(s, e) { SearchOnName(); }" />
                            </dx:ASPxButton>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Telefon
                        </td>
                        <td>
                            <dx:ASPxTextBox ID="txtPhone" ClientInstanceName="txtPhone" runat="server" Width="100px">
                                <ValidationSettings CausesValidation="true" ValidationGroup="SearchOnPhone" RequiredField-IsRequired="true" RequiredField-ErrorText="Indtast telefon" SetFocusOnError="true" ErrorDisplayMode="ImageWithTooltip">
                                    <RequiredField IsRequired="True" ErrorText="Indtast telefon"></RequiredField>
                                </ValidationSettings>
                                <ClientSideEvents KeyDown="function(s, e) {if(ASPxClientUtils.GetKeyCode(e.htmlEvent) ===  ASPxKey.Enter) SearchOnPhone();}" />
                            </dx:ASPxTextBox>
                        </td>
                        <td>
                            <dx:ASPxButton ID="btnPhoneSearch" ClientInstanceName="btnPhoneSearch" runat="server" Text="Søg" AutoPostBack="False" UseSubmitBehavior="False">
                                <ClientSideEvents Click="function(s, e) { SearchOnPhone(); }" />
                            </dx:ASPxButton>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Email
                        </td>
                        <td>
                            <dx:ASPxTextBox ID="txtEmail" ClientInstanceName="txtEmail" runat="server" Width="100px">
                                <ValidationSettings CausesValidation="true" ValidationGroup="SearchOnEmail" RequiredField-IsRequired="true" RequiredField-ErrorText="Indtast email" SetFocusOnError="true" ErrorDisplayMode="ImageWithTooltip">
                                    <RequiredField IsRequired="True" ErrorText="Indtast email"></RequiredField>
                                </ValidationSettings>
                                <ClientSideEvents KeyDown="function(s, e) {if(ASPxClientUtils.GetKeyCode(e.htmlEvent) ===  ASPxKey.Enter) SearchOnEmail();}" />
                            </dx:ASPxTextBox>
                        </td>
                        <td>
                            <dx:ASPxButton ID="btnEmailSearch" ClientInstanceName="btnEmailSearch" runat="server" Text="Søg" AutoPostBack="False" UseSubmitBehavior="False">
                                <ClientSideEvents Click="function(s, e) { SearchOnEmail(); }" />
                            </dx:ASPxButton>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Reg.nr.
                        </td>
                        <td>
                            <dx:ASPxTextBox ID="txtRegistrationNumber" ClientInstanceName="txtRegistrationNumber" runat="server" Width="100px">
                                <ValidationSettings CausesValidation="true" ValidationGroup="SearchOnRegistrationNumber" RequiredField-IsRequired="true" RequiredField-ErrorText="Indtast regnr" SetFocusOnError="true" ErrorDisplayMode="ImageWithTooltip">
                                    <RequiredField IsRequired="True" ErrorText="Indtast regnr"></RequiredField>
                                </ValidationSettings>
                                <ClientSideEvents KeyDown="function(s, e) {if(ASPxClientUtils.GetKeyCode(e.htmlEvent) ===  ASPxKey.Enter) SearchOnRegistrationNumber();}" />
                            </dx:ASPxTextBox>
                        </td>
                        <td>
                            <dx:ASPxButton ID="btnRegistrationNumberSearch" ClientInstanceName="btnRegistrationNumberSearch" runat="server" Text="Søg" AutoPostBack="False" UseSubmitBehavior="False">
                                <ClientSideEvents Click="function(s, e) { SearchOnRegistrationNumber(); }" />
                            </dx:ASPxButton>
                        </td>
                    </tr>
                </table>

                <dx:ASPxGridView ID="gvCustomerSearch" runat="server" ClientInstanceName="gvCustomerSearch" ClientVisible="false" 
                    KeyFieldName="CarId" Width="400px" AutoGenerateColumns="False" EnableCallBacks="true" OnCustomCallback="gvCustomerSearch_CustomCallback">
                    <ClientSideEvents EndCallback="function(s, e) { CustomerSearchEnded(); }" CallbackError="CallBackError" FocusedRowChanged="function(s, e) { CustomerSelected(); }" />
                    <SettingsLoadingPanel Text="Henter&amp;hellip;" Mode="Disabled" />
                    <Settings ShowHeaderFilterButton="false" ShowGroupPanel="false" ShowFilterRow="false" />
                    <SettingsPager AlwaysShowPager="false" PageSize="15" Position="Bottom">
                        <Summary 
                            AllPagesText="Sider: {0} - {1} ({2} resultater)" 
                            Text="Side {0} af {1} ({2} resultater)" />
                    </SettingsPager>
                    <SettingsBehavior ConfirmDelete="True" AllowGroup="false" AllowDragDrop="false" AllowFocusedRow="true" />
                    <Columns>
                        <dx:GridViewDataColumn FieldName="CustomerId" VisibleIndex="0" Caption="CustomerId" Visible="false">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="CarId" VisibleIndex="0" Caption="CarId" Visible="false">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="CustomerSubscriptionId" VisibleIndex="0" Caption="CustomerSubscriptionId" Visible="false">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataHyperLinkColumn FieldName="CustomerId" VisibleIndex="0" Caption="Kundenr">
                            <PropertiesHyperLinkEdit NavigateUrlFormatString="~/View/CustomerView/EditCustomerData.aspx?CustomerId={0}" TextField="CustomerId">
                            </PropertiesHyperLinkEdit>
                        </dx:GridViewDataHyperLinkColumn>
                        <dx:GridViewDataColumn FieldName="Name" VisibleIndex="3" Caption="Navn">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="City" VisibleIndex="6" Caption="By">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="Phone1" VisibleIndex="12" Caption="Telefon">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="Phone2" VisibleIndex="13" Caption="Telefon2">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="Email" VisibleIndex="14" Caption="Email">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="RegistrationNumber" VisibleIndex="15" Caption="Regnr">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn Caption="Hurtig valg" VisibleIndex="16" FieldName="CarId">
                            <DataItemTemplate>
                                <dx:ASPxComboBox ID="ddlSelectQuickAction" ClientInstanceName="ddlSelectQuickAction" runat="server">
                                    <%--<ClientSideEvents SelectedIndexChanged="function(s, e) { SelectQuickAction(s, ); }" />--%>
                                    <ClientSideEvents SelectedIndexChanged="function(s, e){
                                        var quickaction = s.GetValue();
                                        var carid = gvCustomerSearch.GetRowKey(gvCustomerSearch.GetFocusedRowIndex());
                                        SelectQuickAction(quickaction, carid)
                                        s.SetText('');
                                    }" />


                                    <Items>
                                        <dx:ListEditItem Value="4" Text="Bookinglink" />
                                        <dx:ListEditItem Value="0" Text="Opret opgave" />
                                        <dx:ListEditItem Value="1" Text="Oversigt service/Opgaver" />
                                        <dx:ListEditItem Value="2" Text="Udskift bil med ny" />
                                        <dx:ListEditItem Value="3" Text="Opsig / deaktiver" />
                                    </Items>
                                </dx:ASPxComboBox>

                                <%--<a href="javascript:void(0);" onclick="OnMoreInfoClick(this, '<%# Container.KeyValue %>')">
                                    More Info...</a>--%>
                            </DataItemTemplate>
                        </dx:GridViewDataColumn>
                    </Columns>          
                </dx:ASPxGridView>

            </td>
            <td valign="top">
                <table width="210px">
                    <tr>
                        <td colspan="3">
                            <b>Hurtig handling - Kunder</b>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3">
                            <dx:ASPxLabel ID="ASPxLabel1" runat="server" Text="">
                            </dx:ASPxLabel>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3">
                            <b>Hurtig handling - biler</b>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Aktive
                        </td>
                        <td>
                            <dx:ASPxLabel ID="lblActive" runat="server" Text="">
                            </dx:ASPxLabel>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            InAktive
                        </td>
                        <td>
                            <dx:ASPxLabel ID="lblInActive" runat="server" Text="">
                            </dx:ASPxLabel>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Skal have skiftet hjul
                        </td>
                        <td>
                            <dx:ASPxLabel ID="lblNeedsTireChanged" runat="server" Text="">
                            </dx:ASPxLabel>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Har fået skiftet hjul
                        </td>
                        <td>
                            <dx:ASPxLabel ID="lblTireChanged" runat="server" Text="">
                            </dx:ASPxLabel>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Hjulskift planlagt
                        </td>
                        <td>
                            <dx:ASPxLabel ID="lblPlannedTireChange" runat="server" Text="">
                            </dx:ASPxLabel>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Dækmønster opmålt
                        </td>
                        <td>
                            <dx:ASPxLabel ID="lblTireMeasured" runat="server" Text="">
                            </dx:ASPxLabel>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Skal have hentet hjul
                        </td>
                        <td>
                            <dx:ASPxLabel ID="lblNeedsTirePickedUp" runat="server" Text="">
                            </dx:ASPxLabel>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Hjul afhentning planlagt
                        </td>
                        <td>
                            <dx:ASPxLabel ID="lblPlannedTirePickUp" runat="server" Text="">
                            </dx:ASPxLabel>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Skal have leveret hjul tilbage
                        </td>
                        <td>
                            <dx:ASPxLabel ID="lblNeedsTireReturned" runat="server" Text="">
                            </dx:ASPxLabel>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Tilbagelevering af hjul planlagt
                        </td>
                        <td>
                            <dx:ASPxLabel ID="lblPlannedTireReturn" runat="server" Text="">
                            </dx:ASPxLabel>
                        </td>
                    </tr>
                    
                </table>
            </td>
        </tr>
    </table>

                
    <!-- Modalpopup: Show servicedetails (servicedrives and tasks) -->
    <dx:ASPxPopupControl ID="pcShowServiceDetails" ClientInstanceName="pcShowServiceDetails" Modal="true" runat="server" Height="1px" AutoUpdatePosition="true"
        PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter"
        AllowDragging="True" Left="100" Top="100"
        CloseAction="CloseButton" Width="500px" HeaderText="Servicekørsler og opgaver">
        <ContentCollection>
            <dx:PopupControlContentControl ID="PopupControlContentControl1" runat="server">
            
                <dx:ASPxGridView ID="gvService" runat="server" ClientInstanceName="gvService" Width="100%" Caption="Hjulskift og servicekørsler"
                    KeyFieldName="ServiceCarScheduleDetailId" AutoGenerateColumns="False" EnableCallBacks="True"
                    OnCustomCallback="gvService_CustomCallback">
                    <SettingsLoadingPanel Text="Henter&amp;hellip;" />
                    <Settings ShowHeaderFilterButton="false" ShowGroupPanel="false" ShowFilterRow="false" />
                    <SettingsPager AlwaysShowPager="false" PageSize="10" Position="Bottom">
                        <Summary 
                            AllPagesText="Sider: {0} - {1} ({2} servicekørsler)" 
                            Text="Side {0} af {1} ({2} servicekørsler)" />
                    </SettingsPager>
                    <SettingsBehavior ConfirmDelete="True" AllowGroup="true" AllowDragDrop="true" />
                    <Columns>
                        <dx:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0">
                                <HeaderTemplate>
                                    <input type="checkbox" onclick="gvService.SelectAllRowsOnPage(this.checked);" style="vertical-align:middle;" title="Vælg/Fravælg alle linjer på siden"></input>
                                </HeaderTemplate>
                                <HeaderStyle Paddings-PaddingTop="1" Paddings-PaddingBottom="1" 
                                    HorizontalAlign="Center">
                                <Paddings PaddingTop="1px" PaddingBottom="1px"></Paddings>
                                </HeaderStyle>
                        </dx:GridViewCommandColumn>

                        <dx:GridViewDataHyperLinkColumn FieldName="CustomerId" VisibleIndex="5" Caption="Kontakt">
                            <PropertiesHyperLinkEdit NavigateUrlFormatString="~/View/CustomerView/EditCustomerData.aspx?CustomerId={0}" TextField="Name">
                            </PropertiesHyperLinkEdit>
                        </dx:GridViewDataHyperLinkColumn>
                        <dx:GridViewDataColumn FieldName="Name" VisibleIndex="5" Caption="Kontakt" Visible="false">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="ScheduleDate" VisibleIndex="6" Caption="Dato">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="RegistrationNumber" VisibleIndex="6" Caption="Reg.nr.">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataTextColumn FieldName="CarBrandDescription" VisibleIndex="7" Caption="Bilmærke">
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataTextColumn FieldName="FromTireSetDescription" VisibleIndex="7" Caption="Fra">
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataTextColumn FieldName="ToTireSetDescription" VisibleIndex="7" Caption="Til">
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataCheckColumn FieldName="CustomerConfirmed" VisibleIndex="13" Caption="Godkendt">
                        </dx:GridViewDataCheckColumn>
                        <dx:GridViewDataCheckColumn FieldName="WorkCompleted" VisibleIndex="13" Caption="Gennemført">
                        </dx:GridViewDataCheckColumn>
                        <dx:GridViewDataCheckColumn FieldName="CustomerRated" VisibleIndex="13" Caption="Anmeldt">
                        </dx:GridViewDataCheckColumn>
                    </Columns>                                            
                </dx:ASPxGridView>

                <dx:ASPxGridView ID="gvTask" runat="server" ClientInstanceName="gvTask" Width="100%" Caption="Opgaver"
                    KeyFieldName="TaskId" AutoGenerateColumns="False" EnableCallBacks="True"
                    OnCustomCallback="gvTask_CustomCallback">
                    <SettingsLoadingPanel Text="Henter&amp;hellip;" />
                    <Settings ShowHeaderFilterButton="false" ShowGroupPanel="false" ShowFilterRow="false" />
                    <SettingsPager AlwaysShowPager="false" PageSize="10" Position="Bottom">
                        <Summary 
                            AllPagesText="Sider: {0} - {1} ({2} opgaver)" 
                            Text="Side {0} af {1} ({2} opgaver)" />
                    </SettingsPager>
                    <SettingsBehavior ConfirmDelete="True" AllowGroup="true" AllowDragDrop="true" />
                    <Columns>
                        <dx:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0">
                                <HeaderTemplate>
                                    <input type="checkbox" onclick="gvTask.SelectAllRowsOnPage(this.checked);" style="vertical-align:middle;" title="Vælg/Fravælg alle linjer på siden"></input>
                                </HeaderTemplate>
                                <HeaderStyle Paddings-PaddingTop="1" Paddings-PaddingBottom="1" 
                                    HorizontalAlign="Center">
                                <Paddings PaddingTop="1px" PaddingBottom="1px"></Paddings>
                                </HeaderStyle>
                        </dx:GridViewCommandColumn>
                        <dx:GridViewDataColumn Caption="Rediger" Width="106px" VisibleIndex="1">
                            <DataItemTemplate>
                                <a href="javascript:void(0);" onclick="ShowEditTaskModalPopup(this, '<%# Container.KeyValue %>')"><img src="~/Images/Tiny/contract.png" id="img3" runat="server" alt="Opret opgave" /></a>
                            </DataItemTemplate>
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="TaskTypeDescription" VisibleIndex="5" Caption="Opgave">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="TaskTypeStatusDescription" VisibleIndex="6" Caption="Status">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="Createdate" VisibleIndex="6" Caption="Oprettet">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="RegistrationNumber" VisibleIndex="6" Caption="Reg.nr.">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataTextColumn FieldName="TireTypeDescription" VisibleIndex="7" Caption="Dæktype">
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataTextColumn FieldName="DependentTaskId" VisibleIndex="8" Caption="Opgave før">
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataTextColumn FieldName="DependentChildTaskId" VisibleIndex="9" Caption="Opgave efter">
                        </dx:GridViewDataTextColumn>
                    </Columns>
                    <Templates>
                        <DetailRow>
                            Opgavedetaljer
                            <br />
                            <dx:ASPxGridView ID="gvTaskDetail" ClientInstanceName="gvTaskDetail" runat="server" KeyFieldName="TaskDetailId"
                                Width="100%" OnBeforePerformDataSelect="gvTaskDetail_DataSelect">
                                <Columns>
                                    <dx:GridViewDataColumn FieldName="TaskDetailId" Caption="Id" VisibleIndex="1" />
                                    <dx:GridViewDataColumn FieldName="TaskDetailTypeId" Caption="Type" Visible="false" VisibleIndex="2" />
                                    <dx:GridViewDataColumn FieldName="Description" Caption="Beskrivelse" VisibleIndex="2" />
                                    <dx:GridViewDataColumn FieldName="EstimatedTime" Caption="Estimeret tid" VisibleIndex="2" />
                                    <dx:GridViewDataColumn FieldName="Amount" Caption="Antal" VisibleIndex="3" />
                                    <dx:GridViewDataColumn FieldName="NoteToEmployee" Caption="Note" VisibleIndex="4" />
                                    <dx:GridViewDataColumn FieldName="Completed" Caption="Afsluttet" VisibleIndex="5" />
                                    <dx:GridViewDataColumn FieldName="Cancelled" Caption="Annulleret" VisibleIndex="6" />
                                </Columns>
                            </dx:ASPxGridView>
                        </DetailRow>
                    </Templates>
                    <SettingsDetail ShowDetailRow="true" />                                            
                </dx:ASPxGridView>

            </dx:PopupControlContentControl>
        </ContentCollection>
    </dx:ASPxPopupControl>
    

    <!-- Javascript for UserControls implementatation -->
    <script language="javascript" type="text/javascript">

        // Functions for deactivate customersubscription modalpopup
        function ShowDeactivateCustomerSubscriptionModalPopup(element, key) {
            callbackDeactivateCustomerSubscriptionPanel.SetContentHtml("");
            pcDeactivateCustomerSubscription.ShowAtElement(element);
            callbackDeactivateCustomerSubscriptionPanel.PerformCallback(key);
            DeactivateCustomerSubscriptionKeyValue = key;
        }

        function DeactivateCustomerSubscriptionRefreshParent() {
            //Perform action on parent control - ex. refresh gridview with PerformCallback
            
            // Nothing needed here
        }

    </script>
    <uc1:ucDeactivateSubscription ID="ucDeactivateSubscription" runat="server" />

    <!-- Javascript for UserControls implementatation -->
    <script language="javascript" type="text/javascript">

        // Functions for replacing car modalpopup
        function ShowReplaceCarModalPopup(element, key) {
            callbackReplaceCarPanel.SetContentHtml("");
            pcReplaceCar.ShowAtElement(element);
            callbackReplaceCarPanel.PerformCallback(key);
            ReplaceCarKeyValue = key;
        }

        function ReplaceCarRefreshParent() {
            //Perform action on parent control - ex. refresh gridview with PerformCallback
            
            // Nothing needed here
        }

    </script>
    <uc2:ucReplaceCar ID="ucReplaceCar" runat="server" />

    <!-- Javascript for UserControls implementatation -->
    <script language="javascript" type="text/javascript">
        // Functions for create task modalpopup
        function ShowCreateTaskModalPopup(element, key, key2) {
            callbackCreateTaskPanel.SetContentHtml("");
            pcCreateTask.ShowAtElement(element);
            callbackCreateTaskPanel.PerformCallback('NoAction' + '|' + key + '|' + key2);
            //ddlCar.PerformCallback(key.toString());
            CreateTaskCustomerIdKeyValue = key;
        }
    </script>
    <uc3:ucCreateTask ID="ucCreateTask" runat="server" />

    <!-- Javascript for UserControls implementatation -->
    <script language="javascript" type="text/javascript">
        // Functions for edit serviceschedule detail notes modalpopup
        function SendCustomerBookingLinkModalPopup(element, key) {
            callbackSendCustomerBookingLinkPanel.SetContentHtml("");
            pcSendCustomerBookingLink.ShowAtElement(element);
            callbackSendCustomerBookingLinkPanel.PerformCallback(key);
            EditCustomerBookingLinkKeyValue = key;
        }

        function SendCustomerBookingLinkRefreshParent() {
            //Perform action on parent control - ex. refresh gridview with PerformCallback
        }
    </script>
    <uc4:ucCustomerBookingLink ID="ucCustomerBookingLink" runat="server" />
    
    <!-- Javascript for implementation of edittask usercontrol -->
    <script type="text/javascript">

        // Functions for edit task modalpopup
        function ShowEditTaskModalPopup(element, key) {
            callbackEditTaskPanel.SetContentHtml("");
            pcEditTask.ShowAtElement(element);
            callbackEditTaskPanel.PerformCallback(key);
            EditTaskKeyValue = key;
        }

        function EditTaskCompleteRefreshParent() {
            //Perform action on parent control - ex. refresh gridview with PerformCallback
            // Get carid
            gvCustomerSearch.GetRowValues(gvCustomerSearch.GetFocusedRowIndex(), 'CarId', RefreshCustomerServiceDetails);
            
            
        }

        function RefreshCustomerServiceDetails(carid) {
            if (carid == null) return;

            ShowCustomerServiceDetails(carid);
        }

    </script>
    <uc5:ucEditTask ID="ucEditTask" runat="server" />

</asp:Content>
